import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './router/permission'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import './styles/theme.scss'
import './styles/index.scss'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { flexible } from '@/utils/flexible'
import { useThemeStore } from '@/stores/theme'

// 创建vue实例
const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 挂载pinia
const pinia = createPinia()
app.use(pinia)

// 挂载路由
app.use(router)

// 挂载 ElementPlus
app.use(ElementPlus)

// 初始化主题
const themeStore = useThemeStore()
themeStore.initTheme()

// 初始化屏幕自适应
flexible()

// 挂载实例
app.mount('#app') 